<template>
  <div id="container">
    <el-form :model="form" status-icon  ref="form" label-width="100px" class="demo-ruleForm">
       
       
       
    <el-form-item label="注册账号" prop="pass">
    <el-input maxlength="12" show-word-limit type="text" v-model="form.username" autocomplete="off"></el-input>
    </el-form-item>

    <el-form-item label="注册密码" prop="checkPass">
        <el-input maxlength="12" show-word-limit type="password" v-model="form.password" autocomplete="off"></el-input>
    </el-form-item>

    <el-form-item label="重复密码" prop="repetPass">
        <el-input maxlength="12" show-word-limit type="password" v-model="form.repetpassword" autocomplete="off"></el-input>
    </el-form-item>

    </el-form>



    <el-form :model="form2" status-icon  ref="form2" label-width="100px" class="demo-ruleForm">
   
    <el-form-item label="姓名" prop="pname">
    <el-input show-word-limit type="text" v-model="form2.pname" autocomplete="off"></el-input>
    </el-form-item>

    <el-form-item label="身份证号" prop="pcard">
    <el-input maxlength="18" show-word-limit type="text" v-model="form2.pcard" autocomplete="off"></el-input>
    </el-form-item>

    <el-form-item label="联系方式" prop="ptel">
    <el-input maxlength="11" show-word-limit type="text" v-model="form2.ptel" autocomplete="off"></el-input>
    </el-form-item>

    <el-form-item label="性别">
    <el-radio-group v-model="form2.psex">
      <el-radio label="男"></el-radio>
      <el-radio label="女"></el-radio>
    </el-radio-group>
  </el-form-item>

    <el-form-item>
        <el-button type="primary" @click="regist">确认注册</el-button>
        <el-button type="primary" @click="preg">返回上层</el-button>
    </el-form-item>

    </el-form>
  </div>
</template>

<script>
export default {
   data(){
        return{
            form:{
                username:"",
                password:"",
                repetpassword:"",
                flag:"3",
                  
            },
            form2:{
              uid:"",
              pname:"",
              pcard:"",
              ptel:"",   
              psex:""
            }

        };
    },
    methods:{
      regist(){
        if(this.form.password!=this.form.repetpassword){
          this.$message.error("两次输入不一致，请重试");
          return;
        }



         this.$axios.post("http://localhost:8000/auth-serv/author/regist",this.form).then((resp)=>{
          if(resp.data.code==500){
               this.$message.error("该用户名已经被注册，请重试");
               return;
          }

          console.log(resp.data);
          this.form2.uid=resp.data.data;
          this.$axios.post("http://localhost:8000/patient-serv/patientinfo/regist",this.form2).then((resp2)=>{
              if(resp2.data.code==200){
                this.$message.success("注册成功");
                this.$router.push("/User_login");
              }

          })
          

          
        })
        
        
      },

      preg(){
         this.$router.push("/User_login");
      },
    }

}
</script>

<style>

</style>